package com.ctshk.rpc.goods.mapper;

import com.ctshk.rpc.goods.base.CustomBaseMapper;
import com.ctshk.rpc.goods.entity.CommoditySpecifications;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品规格 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-12
 */
public interface CommoditySpecificationsMapper extends CustomBaseMapper<CommoditySpecifications> {
	@Select("SELECT t.id, t.specifications_name_id, t.specifications, t.is_deleted FROM t_commodity_specifications t WHERE t.is_deleted = 0")
	List<CommoditySpecifications> findBatchSpecificationsAll();

	@Select("SELECT t.id, t.specifications_name_id, t.specifications, t.is_deleted FROM t_commodity_specifications t WHERE t.is_deleted = 0 AND t.specifications_name_id = #{specificationsNameId}")
	List<CommoditySpecifications> findBatchSpecificationsByNameId(Long specificationsNameId);
	
	@Delete("DELETE FROM t_commodity_specifications t WHERE t.specifications_name_id = #{specificationsNameId}")
	void deleteBySpecificationsNameId(Long specificationsNameId);

	@Select("SELECT t.id, t.specifications from t_commodity_specifications t WHERE t.is_deleted = 0 AND t.specifications_name_id = #{specificationsNameId}")
	List<CommoditySpecifications> findSpecificationsListByCommodityId(@Param("specificationsNameId") Long specificationsNameId);

	@Select("SELECT t.id, t.specifications from t_commodity_specifications t WHERE t.id = #{id}")
	CommoditySpecifications findSpecificationsById(@Param("id") Long id);
}
